package 并发编程15.线程池;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 可缓存的线程池，创建的工作线程数量几乎没有限制
 *
 * @author idea
 * @data 2019/2/22
 */
public class newCachedThreadPoolDemo {


    public static void main(String[] args) {
        //采用了SynchronousQueue队列
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 10; i++) {
            int index = i;
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println("this is " + index);
                }
            });
        }


    }
}
